{include file="public/header"}

<body>

  <section id="container" class="">
    <!--header start-->
    {include file="public/headtop"}
    <!--header end-->
    <!--sidebar start-->
    <aside>
      <div id="sidebar"  class="nav-collapse ">
        <!-- sidebar menu start-->
        {include file="public/menu" /}
        <!-- sidebar menu end-->
      </div>
    </aside>
    <!--sidebar end-->
    <!--main content start-->
    <section id="main-content">
      <section class="wrapper site-min-height">
        <!-- invoice start-->
        <section>
          <div class="panel panel-primary">
            <!--<div class="panel-heading navyblue"> INVOICE</div>-->
            <div class="panel-body">
              <div class="row invoice-list">
                <div class="text-center corporate-id">
                  <h1>主机一览表</h1>
                </div>

              </div>
              <table class="table table-striped table-hover">
                <thead>
                  <tr>
                    <th class="hidden-phone">#</th>
                    <th>服务器</th>
                    
                    <th>时间/月</th>
                    <th>应付金额</th>
                    <th>实付金额</th>
                    <th class="hidden-phone">优惠</th>
                    
                    <th >创建时间</th>
                    <th class="hidden-phone">支付时间</th>
                    <th>订单状态</th>
                  </tr>
                </thead>
                <tbody>
                  {volist name="orderList" id="order" empty="该账号当前没有账单"}
                  <tr>
                    <td class="hidden-phone">{$order.id}</td>
                    <td>{$order.hostname}</td>
                    <td>{$order.quantity}</td>
                    <td>{$order.shouldment}</td>
                    <td>{$order.payment}</td>
                    <td class="hidden-phone">{$order.discount}</td>
                    <th >{$order.ctime}</th>
                    <th class="hidden-phone">{$order.paytime}</th>
                    <td>

                      {switch name="order.status" }
                      {case value="2"}<a id="pay_{$order.id}"  class="label label-success label-mini" onmouseover="pay_msg({$order.id},'查看')" onmouseout="pay_msg({$order.id},'已开通')" href="/user/host/{$order.hostlistid}.html">已开通</a>{/case}
                      {case value="1"}<a id="pay_{$order.id}"  class="label label-info label-mini" onmouseover="pay_msg({$order.id},'开通')" onmouseout="pay_msg({$order.id},'已支付')" href="javascript:activation({$order.id})">已支付</a>{/case}
                      {case value="0"}<a id="pay_{$order.id}"  class="label label-danger label-mini" title="点击支付"  onmouseover="pay_msg({$order.id},'支付')" onclick="payment({$order.id})" onmouseout="pay_msg({$order.id},'未支付')">未支付</a>{/case}
                      {default /}
                      {/switch}
                      
                    </td>
                  </tr>
                  {/volist}
                </tbody>
              </table>
              <div class="text-right invoice-btn">
                <a class="btn btn-info btn-lg" onclick="javascript:window.print();"><i class="fa fa-print"></i> 打印电子账单 </a>
              </div>
            </div>
          </div>
        </section>
        <div class="row">
          <div class="col-lg-12">
            <section class="panel">
              <div class="panel-body">
                <div class="modal fade" id="EchoMsg" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                  <div class="modal-dialog modal-sm">
                    <div class="modal-content-wrap">
                      <div class="modal-content">
                        <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                          <h4 class="modal-title">消息通知</h4>
                        </div>
                        <div class="modal-body text-center" id="msgVal">

                        </div>
                        <div class="modal-footer">
                          <button class="btn btn-danger" type="button" data-dismiss="modal"> OK</button>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </section>
          </div>
        </div>
        <!-- invoice end-->
      </section>
    </section>
    <!--main content end-->
    <!-- Right Slidebar start -->
    {include file="public/slidright"}
    <!-- Right Slidebar end -->
    <!--footer start-->
    <footer class="site-footer">
      {include file="public/footer"}
    </footer>
    <!--footer end-->
  </section>

  <!-- js placed at the end of the document so the pages load faster -->
  <script src="__STATIC__/js/jquery.js"></script>
  <script src="__STATIC__/js/bootstrap.min.js"></script>
  <script class="include" type="text/javascript" src="__STATIC__/js/jquery.dcjqaccordion.2.7.js"></script>
  <script src="__STATIC__/js/jquery.scrollTo.min.js"></script>
  <script src="__STATIC__/js/jquery.nicescroll.js" type="text/javascript"></script>
  <script src="__STATIC__/js/respond.min.js" ></script>

  <!--right slidebar-->
  <script src="__STATIC__/js/slidebars.min.js"></script>

  <!--common script for all pages-->
  <script src="__STATIC__/js/common-scripts.js"></script>

  <script type="text/javascript">
    function payment(id){
      $.post('', {id: id}, function(data, textStatus, xhr) {
        if(data.code=='200'){
          EchoMsg(data.msg,location.href);
        }else{
          EchoMsg('ERROR：'+data.msg,location.href);
        }
      });
    }
    function EchoMsg(msg,local){
      $('#msgVal').html(msg);
      $('#EchoMsg').modal('show');
      if(local){
        $('#EchoMsg').on('hidden.bs.modal', function () {
          window.location.href = local;
        })
      }
    }
    function pay_msg(id,msg){
      $('#pay_'+id).html(msg);
    }
    function activation(id){
      $('#pay_'+id).attr('disabled','disabled');
      EchoMsg('正在开通主机，请稍等……');
      $.post('', {activation: id}, function(data, textStatus, xhr) {
        if(data.code=='200'){
          EchoMsg(data.msg,'/user/order.html');
        }else{
          EchoMsg('开通失败：'+data.msg);
        }
      });
    }
  </script>
</body>
</html>
